package realQuestion.shenxin;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.Stack;

public class Main4 {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        List<String> gen = gen(s);
        for (String a:gen
             ) {
            System.out.println(a);

        }

    }
    static List<String>  gen(String letters){
        ArrayList<String> result = new ArrayList<>();
        if (letters==null||letters.length()==0){
            return result;
        }
        Stack<Character> stack = new Stack<>();
        backtrack(result,stack,letters,new StringBuilder());
        return  result;

    }
    static  void  backtrack
            (List<String> result,Stack<Character> stack,String letters,
             StringBuilder sb){
        if (sb.length()==letters.length()){
            result.add(sb.toString());
            return;
        }

        for (int i = 0; i < letters.length(); i++) {
            char c = letters.charAt(i);
            if (stack.contains(c)){
                continue;
            }
            stack.push(c);
            sb.append(c);
            backtrack(result, stack, letters, sb);
            sb.deleteCharAt(sb.length()-1);
            stack.pop();
        }

    }

}
